// 发起交易请求 {"id":"46"}
// @ts-ignore
export async function execute(client_id,message_json) {
    let login_characters = G.Characters.get_current_login_characters(client_id);
    let target_characters = _CharactersData.get(message_json["id"]);
    if(target_characters === undefined){
        ClientUtils.send_basic_prompt(client_id,"#R/对方不存在或不在线");
        return;
    }
    if(G.MapUtils.check_characters_distance(login_characters,target_characters,500)){
        ClientUtils.send_basic_prompt(client_id,"#R/距离过远");
        return;
    }
    if (_CharactersTradeData.get(target_characters["id"]) !== undefined ||
        Object.keys(target_characters["摊位数据"]).length > 0 || Object.keys(target_characters["收购数据"]).length > 0) {
        ClientUtils.send_basic_prompt(client_id, "#R/对方正忙，请稍后再试");
        return;
    }
    if (_CharactersTradeData.get(target_characters["id"]) !== undefined ) {
        ClientUtils.send_basic_prompt(client_id, "#R/当前交易还未结束");
        return;
    }
    _CharactersTradeData.set(login_characters["id"],{"target_id":target_characters["id"]});
    _CharactersTradeData.set(target_characters["id"],{"target_id":login_characters["id"]});
    ClientUtils.send_basic_prompt(client_id, `#R/你正在和${target_characters["名称"]}进行交易`);
    ClientUtils.send_characters_basic_prompt(target_characters["id"],  `#R/你正在和${login_characters["名称"]}进行交易`);
    ClientUtils.send_client_message(client_id, 3512,login_characters["召唤兽"]);
    ClientUtils.send_characters_client_message(target_characters["id"], 3512, target_characters["召唤兽"]);
    ClientUtils.send_client_message(client_id, 3513,{"道具":login_characters["行囊"]});
    ClientUtils.send_characters_client_message(target_characters["id"], 3513, {"道具":target_characters["行囊"]});
    ClientUtils.send_client_message(client_id, 3514,{
        "名称":target_characters["名称"],
        "等级":target_characters["等级"],
    });
    ClientUtils.send_characters_client_message(target_characters["id"], 3514, {
        "名称":login_characters["名称"],
        "等级":login_characters["等级"],
    });
}
